/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.smn.dao;

import com.smn.domain.MyUser;
import com.smn.domain.Share;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Abdulaziz
 */
@Stateless
public class ShareFacade extends AbstractFacade<Share> {

    @PersistenceContext(unitName = "sharemenowPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public ShareFacade() {
        super(Share.class);
    }

    public List<Share> findSharesById(MyUser id) {
        try {
            Query q = em.createQuery("SELECT s FROM Share s WHERE s.owner=:id");
            q.setParameter("id", id);
            return q.getResultList();
                
        } catch (Exception ex) {
            System.out.println(ex.getLocalizedMessage());
            return null;
        }
    }
}
